#!/usr/bin/env python

class KalCompileError(Exception):
    pass

class KalParenArgList(object):
    pass
        #self.require('(')
        #self.validators = #self.require(KalKeywordArgList)
        #self.require(')')


class KalAssignmentStatement(object):
    if node.lvalue == None:
        return node.rvalue.compile()
    elif node.lvalue.is_lvalue():
        return node.lvalue.compile() + '=' + node.rvalue.compile() + ';\n'
    else:
        raise KalCompileError, "cannot assign to an rvalue on line %d, column %d" % (node.line_no, node.column_no)
        #self.lvalue = #self.require(KalUnaryExpression)
        #self.rvalue = #self.optional(KalRValue)
        #self.eol = #self.require(KalEOL)


class KalKeyword(object):
    pass
        #self.kw = #self.require(KalName)
        #self.require('=')
        #self.arg = #self.require(KalExpression)


class KalKeywordWithComma(object):
    pass
        #self.kw = #self.require(KalKeyword)
        #self.require(',')


class KalArgList(object):
    pass
        #self.args1 = #self.optional_multiple(KalNameWithComma)
        #self.args2 = #self.require(KalName)


class KalIfStatement(object):
    pass
        #self.require('if')
        #self.condition = #self.require(KalExpression)
        #self.require(':')
        #self.eol = #self.optional(KalEOL)
        #self.true_block = #self.optional_multiple(KalStatement)
        #self.else_block = #self.optional(KalElseBlock)
        #self.require('end')
        #self.optional('if')
        #self.eol = #self.require(KalEOL)


class KalModule(object):
    pass
        #self.members = #self.optional_multiple(KalModuleItem)


class KalForStatement(object):
    pass
        #self.require('for')
        #self.iterant = #self.require(KalName)
        #self.require('in')
        #self.iterable = #self.require(KalExpression)
        #self.eol = #self.require(KalEOL)
        #self.loop_body = #self.optional_multiple(KalStatement)
        #self.require('next')
        #self.iterant_end = #self.optional(KalName)
        #self.eol = #self.require(KalEOL)


class KalRValue(object):
    return node.rvalue.compile()
        #self.require('=')
        #self.rvalue = #self.require(KalExpression)


class KalElseBlock(object):
    pass
        #self.require('else')
        #self.require(':')
        #self.eol = #self.optional(KalEOL)
        #self.false_block = #self.optional_multiple(KalStatement)


class KalTryStatement(object):
    pass
        #self.require('try')
        #self.require(':')
        #self.eol = #self.require(KalEOL)
        #self.try_block = #self.optional_multiple(KalStatement)
        #self.handle_block = #self.require_multiple(KalHandleBlock)
        #self.require('end')
        #self.optional('try')
        #self.eol = #self.require(KalEOL)


class KalClassDefinition(object):
    pass
        #self.item = #self.require(KalPropertyList,KalMethod,KalFunction,KalStatement)


class KalMapExpression(object):
    pass
        #self.require('{')
        #self.expr1 = #self.optional_multiple(KalMapItemWithComma)
        #self.expr2 = #self.require(KalMapItem)
        #self.require('}')


class KalIntegerExpression(object):
    pass
        #self.value = #self.require(KalInteger)


class KalBlankStatement(object):
    pass
        #self.eol = #self.require(KalEOL)


class KalPropertyList(object):
    pass
        #self.require('properties')
        #self.require(':')
        #self.eol = #self.require(KalEOL)
        #self.item = #self.optional_multiple(KalPropertyDefinition)
        #self.require('end')
        #self.optional('properties')
        #self.eol = #self.require(KalEOL)


class KalExpressionWithComma(object):
    pass
        #self.expr = #self.require(KalExpression)
        #self.require(',')


class KalParenExpression(object):
    pass
        #self.require('(')
        #self.expr = #self.require(KalExpression)
        #self.require(')')


class KalExpression(object):
    pass
        #self.lexpr = #self.require(KalUnaryExpression)
        #self.binexpr = #self.optional(KalBinOperand)


class KalClass(object):
    pass
        #self.require('class')
        #self.name = #self.require(KalName)
        #self.require('inherits')
        #self.parent = #self.require(KalName)
        #self.require(':')
        #self.eol = #self.require(KalEOL)
        #self.members = #self.optional_multiple(KalClassDefinition)
        #self.require('end')
        #self.optional('class')
        #self.eol = #self.require(KalEOL)


class KalStringExpression(object):
    pass
        #self.value = #self.require(KalString)


class KalFloatExpression(object):
    pass
        #self.value = #self.require(KalFloat)


class KalWhileStatement(object):
    pass
        #self.require('while')
        #self.condition = #self.require(KalExpression)
        #self.require(':')
        #self.eol = #self.require(KalEOL)
        #self.loop_body = #self.optional_multiple(KalStatement)
        #self.require('end')
        #self.optional('while')
        #self.eol = #self.require(KalEOL)


class KalFile(object):
    pass
        #self.module = #self.require(KalModule)
        #self.eof = #self.require(KalEOF)


class KalKeywordArgList(object):
    pass
        #self.args1 = #self.optional_multiple(KalKeywordWithComma)
        #self.args2 = #self.require(KalKeyword)


class KalReturnStatement(object):
    pass
        #self.require('return')
        #self.value = #self.optional(KalExpression)
        #self.eol = #self.require(KalEOL)


class KalVargSepecifier(object):
    pass
        #self.require('.')
        #self.require('.')
        #self.require('.')


class KalRaiseStatement(object):
    pass
        #self.require('raise')
        #self.exception = #self.require(KalExpression)
        #self.message = #self.require(KalExpression)
        #self.eol = #self.require(KalEOL)


class KalListExpression(object):
    pass
        #self.require('[')
        #self.expr1 = #self.optional_multiple(KalExpressionWithComma)
        #self.expr2 = #self.require(KalExpression)
        #self.require(']')


class KalModuleItem(object):
    pass
        #self.item = #self.require(KalClass,KalFunction,KalStatement)


class KalMethod(object):
    pass
        #self.require('method')
        #self.name = #self.require(KalName)
        #self.require('(')
        #self.arguments = #self.require(KalArgList,KalVargSepecifier)
        #self.require(')')
        #self.require(':')
        #self.eol = #self.require(KalEOL)
        #self.statements = #self.require(KalStatementBlock)
        #self.require('end')
        #self.optional('method')
        #self.eol = #self.require(KalEOL)


class KalUnaryExpression(object):
    pass
        #self.expr = #self.require(KalFloatExpression,KalIntegerExpression,KalStringExpression,KalNamedExpression,KalParenExpression,KalListExpression,KalMapExpression)


class KalFunction(object):
    pass
        #self.require('function')
        #self.name = #self.require(KalName)
        #self.require('(')
        #self.arguments = #self.optional(KalArgList,KalVargSepecifier)
        #self.require(')')
        #self.require(':')
        #self.eol = #self.require(KalEOL)
        #self.statements = #self.optional_multiple(KalStatement)
        #self.require('end')
        #self.optional('function')
        #self.eol = #self.require(KalEOL)


class KalMapItem(object):
    pass
        #self.key = #self.require(KalExpression)
        #self.require(':')
        #self.value = #self.require(KalExpression)


class KalNameWithComma(object):
    pass
        #self.arg = #self.require(KalName)
        #self.require(',')


class KalStatement(object):
    pass
        #self.statement = #self.require(KalIfStatement,KalForStatement,KalWhileStatement,KalReturnStatement,KalTryStatement,KalRaiseStatement,KalAssignmentStatement,KalBlankStatement)


class KalHandleBlock(object):
    pass
        #self.require('handle')
        #self.exception_list = #self.require(KalArgList)
        #self.require(':')
        #self.eol = #self.require(KalEOL)
        #self.handle_block = #self.optional_multiple(KalStatement)


class KalBinOperand(object):
    pass
        #self.op = #self.require(KalBinOp)
        #self.rexpr = #self.require(KalExpression)


class KalPropertyDefinition(object):
    pass
        #self.type = #self.require(KalName)
        #self.args = #self.optional(KalParenArgList)
        #self.name = #self.require(KalName)
        #self.eol = #self.require(KalEOL)


class KalMapItemWithComma(object):
    pass
        #self.item = #self.require(KalMapItem)
        #self.require(',')


class KalNamedExpression(object):
    pass
        #self.value = #self.require(KalName)
